extends Control

@onready var function_card_shop_button = $FunctionCardShopButton
@onready var function_card_shop_audio = $FunctionCardShopAudio
@onready var buy_detail = $BuyDetail
@onready var buy_detail_label = $BuyDetail/BuyDetailLabel
@onready var prop_shop_button = $PropShop/Button

@onready var function_card_detail = $FunctionCardDetail
@onready var buy_success_audio = $FunctionCardDetail/BuySuccessAudio
@onready var shop_part = $FunctionCardDetail/FunctionCardContainer/Shop/ShopPart
@onready var bag_part = $FunctionCardDetail/FunctionCardContainer/Player/PlayerPart/Bag/BagPart
@onready var carry_part = $FunctionCardDetail/FunctionCardContainer/Player/PlayerPart/Carry/CarryPart

@onready var multifunctional_detail = $MultifunctionalDetail
@onready var multifunctional_button = $MultifunctionalButton
@onready var player_all_card = $MultifunctionalDetail/PlayerFunctionCardContainer
@onready var strong_function_container = $MultifunctionalDetail/StrongFunctionContainer

@onready var all_function_card_container = $AllFunctionCardPenal/AllFunctionCardContainer

@onready var hybridization_button = $HybridizationButton
@onready var hybridization_detail = $HybridizationDetail
@onready var player_all_card_for_hybridization = $HybridizationDetail/PlayerFunctionCardContainer
@onready var hybridization_main_card_container = $HybridizationDetail/MainCard/HybridizationContainer
@onready var hybridization_secondary_card_container = $HybridizationDetail/SecondaryCard/HybridizationContainer

var randomFunctionCardArr = [] #每次重新进商店随机的功能牌
var allFunctionCardArr = [] #玩家所有功能牌

#用于购买按钮跳动
var tweenRotForBuyBtn : Tween
var tweenRotForBuyBtnActive := true

func _ready() -> void:
	#展示玩家金币
	showPlayerMoeny()
	#玩家金币开始跳动
	tweenRotForBuyBtn = Tween.new()
	animateBuyBtnJump(function_card_shop_button, tweenRotForBuyBtn)
	animateBuyBtnJump(multifunctional_button, tweenRotForBuyBtn)
	animateBuyBtnJump(hybridization_button, tweenRotForBuyBtn)
	#随机商店功能牌
	randomFuncCard()

#打开功能卡商店
func _on_button_pressed_shop_open() -> void:
	if function_card_detail.visible == true: return
	function_card_shop_audio.play()
	function_card_detail.visible = true
	multifunctional_detail.visible = false
	hybridization_detail.visible = false
	clearSomeContainer()
	showFuncCards(randomFunctionCardArr,shop_part)
	showFuncCards(PlayerDetail.functionCardArr,bag_part)
	showFuncCards(PlayerDetail.functionCardCarryArr,carry_part)


#打开多功能商店
func _on_multifunctional_button_pressed() -> void:
	if multifunctional_detail.visible == true: return
	allFunctionCardArr = []
	$MechanicalDoorAudio.play()
	multifunctional_detail.visible = true
	function_card_detail.visible = false
	hybridization_detail.visible = false
	clearSomeContainer()
	for item in PlayerDetail.functionCardArr:
		allFunctionCardArr.append(item)
	for item in PlayerDetail.functionCardCarryArr:
		allFunctionCardArr.append(item)
	showFuncCards(allFunctionCardArr,player_all_card)

#打开杂交商店
func _on_hybridization_button_pressed() -> void:
	if hybridization_detail.visible == true: return
	$HybridizationDoorAudio.play()
	allFunctionCardArr = []
	hybridization_detail.visible = true
	multifunctional_detail.visible = false
	function_card_detail.visible = false
	clearSomeContainer()
	for item in PlayerDetail.functionCardArr:
		allFunctionCardArr.append(item)
	for item in PlayerDetail.functionCardCarryArr:
		allFunctionCardArr.append(item)
	showFuncCards(allFunctionCardArr,player_all_card_for_hybridization)
	

#关闭功能卡商店
func _on_button_pressed_shop_close() -> void:
	function_card_detail.visible = false
	clearSomeContainer()
	function_card_detail.z_index = 0

#关闭多功能商店
func _on_button_pressed_close_multifunctional() -> void:
	multifunctional_detail.visible = false
	clearSomeContainer()
	multifunctional_detail.z_index = 0

#关闭杂交商店
func _on_button_pressed_close_hybridization_detail() -> void:
	hybridization_detail.visible = false
	clearSomeContainer()
	hybridization_detail.z_index = 0


#focus闪电按钮
func _on_multifunctional_area_mouse_entered() -> void:
	$MultifunctionalLabel.visible = true
#取消focus闪电按钮
func _on_multifunctional_area_mouse_exited() -> void:
	$MultifunctionalLabel.visible = false



#商店按钮浮动效果
func animateBuyBtnJump(button: Button, tween: Tween):
	if not tweenRotForBuyBtnActive:
		return
	var btnPosition = button.position
	tween = create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)	# 向上
	tween.tween_property(button, "position", Vector2(btnPosition.x,btnPosition.y - 20), 1)
	# 向下，再循环
	tween.tween_property(button, "position", Vector2(btnPosition.x,btnPosition.y), 1)
	tween.tween_callback(Callable(self, "animateBuyBtnJump").bind(button, tween))  # 循环调用

#展示玩家金币
func showPlayerMoeny():
	function_card_shop_button.text = str(PlayerDetail.playerMoney)

#展示功能牌
func showFuncCards(functionCardArr,container):
	for item in functionCardArr:
		# 拼接功能牌场景路径
		var scenePath = "res://gameScene/functionCardScene/" + item + "FunctionCard/" + item + "FunctionCard.tscn"
		# 加载场景并确保返回的是一个 PackedScene
		var funcCardScene = load(scenePath)
		# 检查是否是 PackedScene 类型
		if funcCardScene and funcCardScene is PackedScene:  
			# 创建一个 Container 节点作为容器
			var cardContainer = HBoxContainer.new()
			cardContainer.custom_minimum_size = Vector2(100,100)
			# 实例化场景
			var funcCardInstance = funcCardScene.instantiate()
			if funcCardInstance:
				 # 将功能牌添加到 Control 容器中
				cardContainer.add_child(funcCardInstance)
				if container == shop_part:
					# 创建购买按钮
					var buttonBuy = Button.new()
					buttonBuy.custom_minimum_size = Vector2(10,10)
					var iconTexture = load("res://assets/image/icon/Money.png") # 这里换成你的图片路径
					buttonBuy.icon = iconTexture
					buttonBuy.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
					buttonBuy.vertical_icon_alignment = VERTICAL_ALIGNMENT_TOP
					buttonBuy.add_theme_constant_override("icon_max_width", 30)
					buttonBuy.text = str(funcCardInstance.cost)
					buttonBuy.connect("pressed", Callable(self, "_onBuyPressed").bind(funcCardInstance))
					cardContainer.add_child(buttonBuy)
				elif container == bag_part:
					var vboxContainer = VBoxContainer.new()
					var buttonCarry = Button.new()
					buttonCarry.custom_minimum_size = Vector2(10,10)
					buttonCarry.text = "携" + "\n" + "带"
					buttonCarry.connect("pressed", Callable(self, "_onCarryPressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonCarry)
					
					# 创建删除按钮
					var buttonRemove = Button.new()
					buttonRemove.custom_minimum_size = Vector2(20,20)
					buttonRemove.text = "移" + "\n" + "除"
					buttonRemove.connect("pressed", Callable(self, "_onDeletePressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonRemove)
					cardContainer.add_child(vboxContainer)
				elif container == carry_part:
					var vboxContainer = VBoxContainer.new()
					var buttonNoCarry = Button.new()
					buttonNoCarry.custom_minimum_size = Vector2(20,20)
					buttonNoCarry.text = "放" + "\n" + "回"
					buttonNoCarry.connect("pressed", Callable(self, "_onBackPressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonNoCarry)
					cardContainer.add_child(vboxContainer)
				elif container == player_all_card:
					var vboxContainer = VBoxContainer.new()
					var buttonPushIn = Button.new()
					buttonPushIn.custom_minimum_size = Vector2(10,10)
					buttonPushIn.text = "放" + "\n" + "入"
					buttonPushIn.connect("pressed", Callable(self, "_onPushInPressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonPushIn)
					cardContainer.add_child(vboxContainer)
				elif container == strong_function_container:
					var vboxContainer = VBoxContainer.new()
					var buttonCarry = Button.new()
					buttonCarry.custom_minimum_size = Vector2(10,10)
					buttonCarry.text = "强" + "\n" + "化"
					buttonCarry.connect("pressed", Callable(self, "_onStrongPressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonCarry)
					
					# 创建删除按钮
					var buttonRemove = Button.new()
					buttonRemove.custom_minimum_size = Vector2(20,20)
					buttonRemove.text = "取" + "\n" + "回"
					buttonRemove.connect("pressed", Callable(self, "_onStrongBackPressed").bind(funcCardInstance))
					vboxContainer.add_child(buttonRemove)
					cardContainer.add_child(vboxContainer)
				elif container == all_function_card_container:
					pass
				elif container == player_all_card_for_hybridization:
					var vboxContainer = VBoxContainer.new()
					var buttonMain = Button.new()
					buttonMain.custom_minimum_size = Vector2(10,10)
					buttonMain.text = "入" + "\n" + "主"
					buttonMain.connect("pressed", Callable(self, "_onPushMain").bind(funcCardInstance))
					vboxContainer.add_child(buttonMain)
					
					var buttonSecondary = Button.new()
					buttonSecondary.custom_minimum_size = Vector2(20,20)
					buttonSecondary.text = "入" + "\n" + "副"
					buttonSecondary.connect("pressed", Callable(self, "_onPushSecondary").bind(funcCardInstance))
					vboxContainer.add_child(buttonSecondary)
					cardContainer.add_child(vboxContainer)
				elif container == hybridization_main_card_container:
					var vboxContainer = VBoxContainer.new()
					var buttonBack = Button.new()
					buttonBack.custom_minimum_size = Vector2(10,10)
					buttonBack.text = "取" + "\n" + "回"
					buttonBack.connect("pressed", Callable(self, "_onBackMain").bind(funcCardInstance))
					vboxContainer.add_child(buttonBack)
					cardContainer.add_child(vboxContainer)
				elif container == hybridization_secondary_card_container:
					var vboxContainer = VBoxContainer.new()
					var buttonMain = Button.new()
					buttonMain.custom_minimum_size = Vector2(10,10)
					buttonMain.text = "杂" + "\n" + "交"
					buttonMain.connect("pressed", Callable(self, "_onHybridization").bind(funcCardInstance))
					vboxContainer.add_child(buttonMain)
					
					var buttonSecondary = Button.new()
					buttonSecondary.custom_minimum_size = Vector2(20,20)
					buttonSecondary.text = "取" + "\n" + "回"
					buttonSecondary.connect("pressed", Callable(self, "_onBackSecondary").bind(funcCardInstance))
					vboxContainer.add_child(buttonSecondary)
					cardContainer.add_child(vboxContainer)
				container.add_child(cardContainer)
			else:
				print("===未找到该资源===")
		else:
			print("===未找到该资源===")

#随机Shop功能牌
func randomFuncCard():
	var random_count = randi() % 4  # 随机决定选择 0,1,2 个元素
	match random_count:
		3,2:
			# 若数组不够2个，直接返回空
			if ShopDetail.functionCardArr.size() < 2:
				return []
			# 获取两个不同的随机索引
			var index1 = randi() % ShopDetail.functionCardArr.size()
			var index2 = randi() % ShopDetail.functionCardArr.size()
			# 确保 index1 和 index2 不相同
			while index1 == index2:
				index2 = randi() % ShopDetail.functionCardArr.size()
			randomFunctionCardArr = [ShopDetail.functionCardArr[index1], ShopDetail.functionCardArr[index2]]
		
		1,0:
			# 若数组不够1个，直接返回空
			if ShopDetail.functionCardArr.size() < 1:
				return []
			# 随机选择一个元素
			var index = randi() % ShopDetail.functionCardArr.size()
			randomFunctionCardArr = [ShopDetail.functionCardArr[index]]
	
#清空容器
func clear_container(container: Node):
	for c in container.get_children():
		container.remove_child(c)
		c.queue_free()

#购买按钮
func _onBuyPressed(funcCardInstance):
	var cost = funcCardInstance.cost
	var funcCardId = funcCardInstance.card_id
	buy_detail.visible = true
	if cost > PlayerDetail.playerMoney:
		buy_detail_label.text = "你没那么多钱！"
	else:
		if PlayerDetail.functionCardArr.size() < 5:
			buy_detail_label.text = "不错的选择～"
			buy_success_audio.play(0.50) #播放购买音效
			PlayerDetail.playerMoney -= cost #更新玩家金币
			showPlayerMoeny() #更新玩家金币文本
			PlayerDetail.functionCardArr.append(funcCardId) #更新玩家功能卡数组
			ShopDetail.functionCardArr.erase(funcCardId) #更新商店功能卡数组
			randomFunctionCardArr.erase(funcCardId)
			clear_container(shop_part) #清空区域后重新渲染
			showFuncCards(randomFunctionCardArr,shop_part) #重新渲染商店功能卡牌区域
			clear_container(bag_part)
			showFuncCards(PlayerDetail.functionCardArr,bag_part) #重新渲染玩家功能卡牌区域
		else:
			buy_detail_label.text = "你的背包满了～"
	await get_tree().create_timer(1).timeout  # 等待
	buy_detail.visible = false

#删除按钮
func _onDeletePressed(funcCardInstance):
	var funcCardId = funcCardInstance.card_id
	clear_container(bag_part) #清空区域后重新渲染
	PlayerDetail.functionCardArr.erase(funcCardId) #更新玩家功能卡数组
	showFuncCards(PlayerDetail.functionCardArr,bag_part) #重新渲染玩家功能卡牌区域

#携带按钮
func _onCarryPressed(funcCardInstance):
	if PlayerDetail.functionCardCarryArr.size() > 4:
		$PlayerCarryDetail.visible = true
		$PlayerCarryDetail/PlayerCarryDetailLabel.text = "你带不了那么多～"
		await get_tree().create_timer(1).timeout  # 等待
		$PlayerCarryDetail.visible = false
	else:
		$Ding.play()
		var funcCardId = funcCardInstance.card_id
		PlayerDetail.functionCardCarryArr.append(funcCardId) #更新玩家携带功能卡数组
		clear_container(carry_part) #清空区域后重新渲染
		showFuncCards(PlayerDetail.functionCardCarryArr,carry_part) #重新渲染玩家功能卡牌区域
		PlayerDetail.functionCardArr.erase(funcCardId) #更新玩家功能卡数组
		clear_container(bag_part) #清空区域后重新渲染
		showFuncCards(PlayerDetail.functionCardArr,bag_part) #重新渲染玩家功能卡牌区域
	
#放回按钮
func _onBackPressed(funcCardInstance):
	$Ding.play()
	var funcCardId = funcCardInstance.card_id
	PlayerDetail.functionCardCarryArr.erase(funcCardId) #更新玩家携带功能卡数组
	clear_container(carry_part) #清空区域后重新渲染
	showFuncCards(PlayerDetail.functionCardCarryArr,carry_part) #重新渲染玩家功能卡牌区域
	PlayerDetail.functionCardArr.append(funcCardId) #更新玩家功能卡数组
	clear_container(bag_part) #清空区域后重新渲染
	showFuncCards(PlayerDetail.functionCardArr,bag_part) #重新渲染玩家功能卡牌区域

#放入强化按钮
func _onPushInPressed(funcCardInstance):
	if strong_function_container.get_children().size() > 0:return
	var currentStrongCard = [funcCardInstance.card_id]
	allFunctionCardArr.erase(funcCardInstance.card_id)
	clear_container(player_all_card)
	showFuncCards(allFunctionCardArr,player_all_card)
	showFuncCards(currentStrongCard,strong_function_container)

#放入杂交主按钮
func _onPushMain(funcCardInstance):
	if hybridization_main_card_container.get_children().size() > 0:return
	if funcCardInstance.can_hybridization == false:
		$PlayerCarryDetail.visible = true
		$PlayerCarryDetail/PlayerCarryDetailLabel.text = "灰牌不能放入～"
		await get_tree().create_timer(1).timeout  # 等待
		$PlayerCarryDetail.visible = false
		return
	
	var currentHybridizationCard = [funcCardInstance.card_id]
	allFunctionCardArr.erase(funcCardInstance.card_id)
	clear_container(player_all_card_for_hybridization)
	showFuncCards(allFunctionCardArr,player_all_card_for_hybridization)
	showFuncCards(currentHybridizationCard,hybridization_main_card_container)
	
#放入杂交副按钮
func _onPushSecondary(funcCardInstance):
	if hybridization_secondary_card_container.get_children().size() > 0:return
	if funcCardInstance.can_hybridization == false:
		$PlayerCarryDetail.visible = true
		$PlayerCarryDetail/PlayerCarryDetailLabel.text = "灰牌不能放入～"
		await get_tree().create_timer(1).timeout  # 等待
		$PlayerCarryDetail.visible = false
		return
	
	var currentHybridizationCard = [funcCardInstance.card_id]
	allFunctionCardArr.erase(funcCardInstance.card_id)
	clear_container(player_all_card_for_hybridization)
	showFuncCards(allFunctionCardArr,player_all_card_for_hybridization)
	showFuncCards(currentHybridizationCard,hybridization_secondary_card_container)
	
#取回杂交主按钮
func _onBackMain(funcCardInstance):
	clear_container(hybridization_main_card_container)
	allFunctionCardArr.append(funcCardInstance.card_id)
	clear_container(player_all_card_for_hybridization)
	showFuncCards(allFunctionCardArr,player_all_card_for_hybridization)

#取回杂交副按钮
func _onBackSecondary(funcCardInstance):
	clear_container(hybridization_secondary_card_container)
	allFunctionCardArr.append(funcCardInstance.card_id)
	clear_container(player_all_card_for_hybridization)
	showFuncCards(allFunctionCardArr,player_all_card_for_hybridization)

#杂交按钮
func _onHybridization(funcCardInstance):
	if hybridization_main_card_container.get_children().size() == 0:
		$PlayerCarryDetail.visible = true
		$PlayerCarryDetail/PlayerCarryDetailLabel.text = "未选择主牌～"
		await get_tree().create_timer(1).timeout  # 等待
		$PlayerCarryDetail.visible = false
		return
	else:
		#有主牌
		var mainFunctionCard = hybridization_main_card_container.get_children()[0].get_children()[0]
		if mainFunctionCard.trigger_timing != funcCardInstance.trigger_timing:
			$PlayerCarryDetail.visible = true
			$PlayerCarryDetail/PlayerCarryDetailLabel.text = "颜色不一致！乱来！"
			await get_tree().create_timer(1).timeout  # 等待
			$PlayerCarryDetail.visible = false
		else:
			var currentCardId = funcCardInstance.card_id
			var mainCardId = mainFunctionCard.card_id
			var tween = Tween.new()
			tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK).set_parallel(true)
			tween.tween_property(funcCardInstance, "position", Vector2(funcCardInstance.position.x - 280 , funcCardInstance.position.y), 1)
			tween.tween_property(funcCardInstance, "modulate:a", 0.0, 1)
			await get_tree().create_timer(1).timeout  # 等待
			$HybridizationDetail/HybridizationAudio.play()
			await strongTween(mainFunctionCard)
			startHybridization(mainCardId,currentCardId)
			clear_container(hybridization_secondary_card_container)
			
#杂交逻辑
func startHybridization(mainId,secondaryId):
	print("杂交=",mainId," + ",secondaryId)
	var result = randi() % 3
	if result == 1 or result == 2:
		FunctionCardStrongLevel.addCardArr[mainId].append(secondaryId)
		$HybridizationDetail/MainCard/SuccessOrLose.text = "成功～"
		$HybridizationDetail/MainCard/SuccessOrLose.visible = true
	else:
		$HybridizationDetail/MainCard/SuccessOrLose.text = "失败～"
		$HybridizationDetail/MainCard/SuccessOrLose.visible = true
	await get_tree().create_timer(0.5).timeout  # 等待
	$HybridizationDetail/MainCard/SuccessOrLose.visible = false
	if PlayerDetail.functionCardArr.has(secondaryId):
		PlayerDetail.functionCardArr.erase(secondaryId)
	else:
		PlayerDetail.functionCardCarryArr.erase(secondaryId)
#强化按钮
func _onStrongPressed(funcCardInstance):
	if PlayerDetail.playerMoney < 5:
		buy_detail.visible = true
		buy_detail_label.text = "你没那么多钱！"
		await get_tree().create_timer(1).timeout  # 等待
		buy_detail.visible = false
		return
	strong_function_container.get_children()[0].get_children()[1].visible = false
	PlayerDetail.playerMoney -= 5
	showPlayerMoeny() #更新玩家金币文本
	#强化动画效果
	strongTween(funcCardInstance)
	$MultifunctionalDetail/MechanicalStrongAudio.play()
	var currentCardId = funcCardInstance.card_id
	var currentLevel = FunctionCardStrongLevel.strongLevelMapping[currentCardId]
	var successProbability = 1.0 / (currentLevel * 2)
	$MultifunctionalDetail/SuccessProbabilityLabel.text = "成功概率：" + str(round(successProbability * 100 * 100) / 100) + "%";
	$MultifunctionalDetail/SuccessProbabilityLabel.visible = true
	await get_tree().create_timer(1).timeout  # 等待1s
	$MultifunctionalDetail/SuccessProbabilityLabel.visible = false
	# 生成一个 0 到 1 之间的随机数
	var randomValue = randf()
	# 判断是否成功
	await get_tree().create_timer(0.5).timeout #等待0.5s
	if randomValue <= successProbability:
		$MultifunctionalDetail/SuccessOrLose.text = "强化成功！强化+1"
		$MultifunctionalDetail/SuccessOrLose.visible = true
		FunctionCardStrongLevel.strongLevelMapping[currentCardId] += 1
		await get_tree().create_timer(0.5).timeout #等待0.5s
		$MultifunctionalDetail/SuccessOrLose.visible = false
		
		#更新强化区域的卡牌
		clear_container(strong_function_container)
		showFuncCards([currentCardId],strong_function_container)
	else:
		$MultifunctionalDetail/SuccessOrLose.text = "强化失败～"
		$MultifunctionalDetail/SuccessOrLose.visible = true
		await get_tree().create_timer(0.5).timeout #等待0.5s
		$MultifunctionalDetail/SuccessOrLose.visible = false
	strong_function_container.get_children()[0].get_children()[1].visible = true

#强化取回按钮
func _onStrongBackPressed(funcCardInstance):
	clear_container(strong_function_container)
	allFunctionCardArr.append(funcCardInstance.card_id)
	clear_container(player_all_card)
	showFuncCards(allFunctionCardArr,player_all_card)
	
#强化抖动特效
func strongTween(funcCardInstance):
	var original_rotation = funcCardInstance.rotation_degrees
	for i in range(16):
		#右摆
		funcCardInstance.pivot_offset = funcCardInstance.size * 0.5
		funcCardInstance.rotation_degrees = original_rotation + 15
		funcCardInstance.scale = Vector2(1.1,1.1)
		await get_tree().create_timer(0.01).timeout  # 等待0.1s
		# 转回原位
		funcCardInstance.scale = Vector2(1.0,1.0)
		funcCardInstance.rotation_degrees = original_rotation
		await get_tree().create_timer(0.01).timeout  # 等待0.1s
		#左摆
		funcCardInstance.rotation_degrees = original_rotation - 15
		funcCardInstance.scale = Vector2(1.1,1.1)
		await get_tree().create_timer(0.01).timeout  # 等待0.1s
		# 转回原位
		funcCardInstance.scale = Vector2(1.0,1.0)
		funcCardInstance.rotation_degrees = original_rotation
		await get_tree().create_timer(0.01).timeout  # 等待0.1s

#功能牌一览
func _on_all_function_card_show_pressed() -> void:
	$AllFunctionCardPenal.visible = true
	function_card_detail.visible = false
	multifunctional_detail.visible = false
	hybridization_detail.visible = false
	clearSomeContainer()
	showFuncCards(ShopDetail.originalFunctionCardArr,all_function_card_container)

#关闭功能牌一览
func _on_close_all_function_card_penal_pressed() -> void:
	$AllFunctionCardPenal.visible = false
	clear_container(all_function_card_container)

#清空各种容器
func clearSomeContainer():
	clear_container(shop_part)
	clear_container(bag_part)
	clear_container(carry_part)
	clear_container(player_all_card)
	clear_container(all_function_card_container)
	clear_container(strong_function_container)
	clear_container(player_all_card_for_hybridization)
	clear_container(hybridization_main_card_container)
	clear_container(hybridization_secondary_card_container)
